package com.tyx.modules.manage.controller;

import com.tyx.common.exception.ErrorEnum;
import com.tyx.common.exception.ServiceException;
import com.tyx.common.utils.R;
import com.tyx.modules.manage.service.PractitionersService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.ArrayList;
import java.util.List;

@RestController
@RequestMapping("/wechat")
public class WechatController {


    @Autowired
    PractitionersService practitionersService;

    @RequestMapping("/getUserList")
    public R getUserList(String name){
        if(name == null){
            R.error(ErrorEnum.PARAMETEREMPTY.getCode(),ErrorEnum.PARAMETEREMPTY.getMsg());
        }
        if(name.length() <= 1){
            return R.error(ErrorEnum.LENGTHERROR.getCode(),ErrorEnum.LENGTHERROR.getMsg());
        }
        List list = practitionersService.getListByName(name);
        if(list == null || list.size() ==0){
            list = new ArrayList();
        }
        return R.ok().put("data",list);
    }
}
